<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
	<f:view>
		<ui:composition template="/template/templatePadrao.xhtml">
			<ui:define name="body">
				<h:outputText value="Contas a Receber > Listagem" styleClass="breadcrumb"/>
			
				<h:form id="form">
					<p:growl id="growl" />
					
					<p:panel header="Filtros" styleClass="filtros" id="panel_filtros">
						<h:panelGrid columns="2">
							<h:outputText value="Pedido" />
							<h:outputText value="Status" />
							
							<p:inputText value="#{contasReceberManager.contasReceber.pedidoVenda.numeroPedido}" />
							<h:selectOneRadio value="#{contasReceberManager.contasReceber.quitado}">
								<f:selectItem itemLabel="Todos" />
								<f:selectItem itemLabel="Pago" itemValue="true"/>
								<f:selectItem itemLabel="Em Aberto" itemValue="false"/>
							</h:selectOneRadio>
							
						
							<p:commandButton value="Procurar" action="#{contasReceberManager.search}" update=":form" process=":form:panel_filtros"/>
						
						</h:panelGrid>
					</p:panel>
								
					
					
					<p:dataTable value="#{contasReceberManager.list}" var="m" rows="3" paginator="true"
						emptyMessage="Não existem resultados.">
						<p:column headerText="Pedido">
							<h:outputText value="#{m.pedidoVenda.numeroPedido}" />
						</p:column>
						<p:column headerText="Parcela">
							<h:outputText value="#{m.numeroParcela}" />
						</p:column>
						<p:column headerText="Data">
							<h:outputText value="#{m.dataPrevisaoPagamento}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</p:column>
						<p:column headerText="Valor">
							<h:outputText value="R$ " />
							<h:outputText value="#{m.valorTotal}" rendered="#{!m.quitado}">
								<f:convertNumber pattern="#,##0.00;(#,##0.00)" />
							</h:outputText>
							<h:outputText value="#{m.valorPagamento}" rendered="#{m.quitado}">
								<f:convertNumber pattern="#,##0.00;(#,##0.00)" />
							</h:outputText>
						</p:column>
						<p:column headerText="Status">
							<h:outputText value="#{m.quitado?'Pago':'Em Aberto'}" />
						</p:column>
						
						<p:column headerText="Ação">
							<p:commandButton action="#{contasReceberManager.showContasReceber}"
								title="Exibir"
								update=":form_parcela"
								icon="ui-icon-search" oncomplete="parcela_dlg.show();">
								<f:setPropertyActionListener target="#{contasReceberManager.contasReceber}" 
									value="#{m}" />
							</p:commandButton>
						</p:column>
						
					</p:dataTable>
				</h:form>
				
				<p:dialog widgetVar="parcela_dlg" 
					width="400" height="400" position="center"
					modal="true"
					resizable="false"
					header="Quitação de Parcelas" 
					style="overflow:auto;">
					<h:form id="form_parcela">
						<ui:include src="/financeiro/paginas/contasReceber/detalheContasReceber.xhtml" />
					</h:form>
				</p:dialog>
				
			</ui:define>
		</ui:composition>
	</f:view>
</html>